import request from '@/util/request'

// 获取监管账号列表
export function listSuperviseAccount () {
  return request({
    url: '/supervised-preOrder/listSuperviseAccount.json',
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取监管账号预选单列表
export function listSupervisedPreorder (pageParams, data) {
  const { index, size } = pageParams
  const { mainId, orderBatch, childName } = data
  return request({
    url: `/supervised-preOrder/listSupervisedPreorder/${index}/${size}.json`,
    method: 'get',
    headers: {
      mainId: mainId,
      childName: childName,
      orderBatch: orderBatch
    },
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取监管账户预选单详情主要信息
export function getPreOrderDetail (orderBatch, mainId) {
  return request({
    url: `/supervised-preOrder/mainDetail/${orderBatch}.json`,
    method: 'get',
    headers: {
      mainId: mainId
    },
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取监管账户预选单详情商品信息
export function listProductDetail (orderBatch, mainId) {
  return request({
    url: `/supervised-preOrder/listPushProduct/${orderBatch}.json`,
    method: 'get',
    headers: {
      mainId: mainId
    },
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 监管账户审批预选单
export function audit (params) {
  const { mainId } = params
  delete params.mainId
  return request({
    url: '/supervised-preOrder/preOrder/audit.json',
    method: 'post',
    data: params,
    headers: {
      mainId: mainId
    },
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取审批记录列表
export function listSuperviseApprove (pagaParams, orderBatch) {
  const { index, size } = pagaParams
  return request({
    url: `/supervised-preOrder/listApprove/${orderBatch}/${index}/${size}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取审批清单
export function getApprovalDetail (id) {
  return request({
    url: `/supervised-preOrder/getApprovalDetail/${id}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 计算运费
export function freight (data) {
  return request({
    url: 'supervised-preOrder/freight.json',
    method: 'POST',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

// 获取子账号列表
export function listChildAccount (mainId) {
  return request({
    url: `/supervised-preOrder/listPushedChild/${mainId}.json`,
    method: 'get',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}
